package com.warmlight.voicepacket.fragment;

import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.github.siyamed.shapeimageview.CircularImageView;
import com.google.gson.Gson;
import com.umeng.analytics.MobclickAgent;
import com.warmlight.voicepacket.R;
import com.warmlight.voicepacket.adapter.MyPlaylistAdapter;
import com.warmlight.voicepacket.base.BaseFragment;
import com.warmlight.voicepacket.data.UserCenterData;
import com.warmlight.voicepacket.data.eventbus.JPush;
import com.warmlight.voicepacket.data.eventbus.Login;
import com.warmlight.voicepacket.data.eventbus.LoginFloat;
import com.warmlight.voicepacket.data.eventbus.NotifyMyPlaylist;
import com.warmlight.voicepacket.dbdata.DBFloatPlaylist;
import com.warmlight.voicepacket.dbmanager.DBFloatPlayListDaoHelp;
import com.warmlight.voicepacket.http.Callback;
import com.warmlight.voicepacket.http.HttpClient;
import com.warmlight.voicepacket.http.HttpConfig;
import com.warmlight.voicepacket.http.ResponseData;
import com.warmlight.voicepacket.ui.setting.SettingActivity;
import com.warmlight.voicepacket.ui.user.LoginRegistActivity;
import com.warmlight.voicepacket.ui.user.MyMessageActivity;
import com.warmlight.voicepacket.ui.user.UserEditInformation;
import com.warmlight.voicepacket.ui.user.fragment.MyDynamicFragment;
import com.warmlight.voicepacket.ui.user.usercenter.MyCoverFragment;
import com.warmlight.voicepacket.ui.user.usercenter.MySoundFragment;
import com.warmlight.voicepacket.ui.user.usercenter.UserCenterViewpagerAdapter;
import com.warmlight.voicepacket.utils.ImConnect;
import com.warmlight.voicepacket.utils.JSONUtils;
import com.warmlight.voicepacket.utils.MobClickHelper;
import com.warmlight.voicepacket.utils.SPUtils;
import com.zhuge.analysis.stat.ZhugeSDK;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

import cn.jpush.android.api.JPushInterface;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.rong.imkit.RongIM;
import io.rong.imkit.manager.IUnReadMessageObserver;
import io.rong.imlib.model.Conversation;
import okhttp3.Call;

public class MeFragment extends BaseFragment implements View.OnClickListener {

    private ImageButton ib_setting;
    private CircularImageView ci_header;
    private TextView tv_nickname;
    private TextView tv_id;
    private TextView tv_age;
    private TextView tv_gander;
    private TextView tv_sign;
//    private ImageView iv_add_cover;
//    private ListView lv_my_playlist;
//    private MyCoverListOnNetAdapter adapter;
    private LinearLayout ll_login;
    private LinearLayout ll_nologin;
    private MyPlaylistAdapter mMyPlaylistAdapter;
    private List<DBFloatPlaylist> mPlaylist;
    private ImageView iv_edit;
    private RelativeLayout rl_msg;
    private TextView tv_msg_num;
    private IUnReadMessageObserver iUnReadMessageObserver;
    private int integer_msg_num;
    private int chat_msg_num;
    private TabLayout tabLayout;
    private ViewPager viewPager;
    private UserCenterViewpagerAdapter userCenterViewpagerAdapter;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        mView = inflater.inflate(R.layout.fragment_me, container, false);
        EventBus.getDefault().register(this);
        return mView;
    }

    @Override
    public void onHiddenChanged(boolean hidden) {
        super.onHiddenChanged(hidden);
        if (hidden){
            if (userCenterViewpagerAdapter != null){
                MyDynamicFragment myDynamicFragment = (MyDynamicFragment) userCenterViewpagerAdapter.getItem(2);
                myDynamicFragment.stopVideo();
            }
        }
    }


    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        initViews();
        initListener();
        initViewPager();
        initData();
    }

    private void initViewPager() {
        TabLayout.Tab tab1 = tabLayout.newTab();
        tab1.setText("收藏");
        tabLayout.addTab(tab1);

        TabLayout.Tab tab2 = tabLayout.newTab();
        tab2.setText("声音");
        tabLayout.addTab(tab2);

        TabLayout.Tab tab3 = tabLayout.newTab();
        tab3.setText("动态");
        tabLayout.addTab(tab3);

        MyCoverFragment myCoverFragment = new MyCoverFragment();
        MySoundFragment myCoverFragment2 = new MySoundFragment();
        MyDynamicFragment myCoverFragment3 = new MyDynamicFragment();

        List<Fragment> fragments = new ArrayList<>();
        fragments.add(myCoverFragment);
        fragments.add(myCoverFragment2);
        fragments.add(myCoverFragment3);

        userCenterViewpagerAdapter = new UserCenterViewpagerAdapter(getChildFragmentManager(),getContext(),fragments);
        viewPager.setAdapter(userCenterViewpagerAdapter);
        tabLayout.setupWithViewPager(viewPager);

        viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }

            @Override
            public void onPageSelected(int position) {
                if (SPUtils.isLogined()) {
                    if (position == 0) {
                        MobclickAgent.onEvent(getContext(), MobClickHelper.PROFILE_TAB_CLOT);
                    } else if (position == 1) {
                        MobclickAgent.onEvent(getContext(), MobClickHelper.PROFILE_TAB_VOICE);
                    } else if (position == 2) {
                        MobclickAgent.onEvent(getContext(), MobClickHelper.PROFILE_TAB_STATUS);
                    }
                }else{
                    if (position == 0) {
                        MobclickAgent.onEvent(getContext(), MobClickHelper.PROFILE_TAB_OUTCLOT);
                    } else if (position == 1) {
                        MobclickAgent.onEvent(getContext(), MobClickHelper.PROFILE_TAB_OUTVOICE);
                    } else if (position == 2) {
                        MobclickAgent.onEvent(getContext(), MobClickHelper.PROFILE_TAB_OUTSTATUS);
                    }
                }
            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });
    }

    /**
     * 每次请求数据保证消息的数量有效性
     */
    @Override
    public void onResume() {
        super.onResume();
        if (SPUtils.isLogined()) {
            loadData();
        }
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        EventBus.getDefault().unregister(this);
    }
    //订阅方法，当接收到事件的时候，会调用该方法
    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEvent(NotifyMyPlaylist data){
        if (SPUtils.isLogined()){
            refresh();
        }else {
            queryMyList();
        }
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void xxx(Login login){
        initData();
        if (SPUtils.isLogined()){
            if (iUnReadMessageObserver != null) {
                RongIM.getInstance().addUnReadMessageCountChangedObserver(iUnReadMessageObserver, Conversation.ConversationType.PRIVATE);
            }
        }else {
            if (iUnReadMessageObserver != null) {
                RongIM.getInstance().removeUnReadMessageCountChangedObserver(iUnReadMessageObserver);
            }
        }

    }


    private void initViews(){
        ib_setting = (ImageButton) findViewById(R.id.ib_setting);
        ci_header = (CircularImageView) findViewById(R.id.ci_header);
        tv_nickname = (TextView) findViewById(R.id.tv_nickname);
        tv_id = (TextView) findViewById(R.id.tv_id);
        tv_age = (TextView) findViewById(R.id.tv_age);
        tv_gander = (TextView) findViewById(R.id.tv_gander);
        tv_sign = (TextView) findViewById(R.id.tv_sign);
//        iv_add_cover = (ImageView) findViewById(R.id.iv_add_cover);
//        lv_my_playlist = (ListView) findViewById(R.id.lv_my_playlist);
        ll_login = (LinearLayout) findViewById(R.id.ll_login);
        ll_nologin = (LinearLayout) findViewById(R.id.ll_nologin);
        iv_edit = (ImageView) findViewById(R.id.iv_edit);
        //我的消息
        rl_msg = (RelativeLayout) findViewById(R.id.rl_msg);
        ImageView iv_msg = (ImageView) findViewById(R.id.iv_msg);
        tv_msg_num = (TextView) findViewById(R.id.tv_msg_num);

        tabLayout = (TabLayout) findViewById(R.id.tabs);
        viewPager = (ViewPager) findViewById(R.id.viewpager);
    }

    private void initListener(){
        ib_setting.setOnClickListener(this);
        ll_nologin.setOnClickListener(this);
        ci_header.setOnClickListener(this);
        rl_msg.setOnClickListener(this);
//        ll_login.setOnClickListener(this);

        iUnReadMessageObserver=new IUnReadMessageObserver() {//监听消息数
            @Override
            public void onCountChanged(int i) {
//                String s = tv_msg_num.getText().toString();
                chat_msg_num = i;
                setMsgNum(chat_msg_num,integer_msg_num);
            }
        };
        RongIM.getInstance().addUnReadMessageCountChangedObserver(iUnReadMessageObserver, Conversation.ConversationType.PRIVATE);
    }

    private void refresh(){
        loadData();
    }

    /**
     * 设置消息数量
     * @param chat_msg_num 聊天消息数量
     * @param integer_msg_num 点赞消息数量
     */
    private void setMsgNum(int chat_msg_num,int integer_msg_num){
        int num = chat_msg_num + integer_msg_num;
        if (num != 0){
            if (num>99){
                tv_msg_num.setText("99+");
            }else{
                tv_msg_num.setText(num+"");
            }
            tv_msg_num.setVisibility(View.VISIBLE);
        }else{
            tv_msg_num.setVisibility(View.GONE);
        }
    }

    private void initData(){
//        boolean ltn = SPUtils.getBoolean(SPUtils.LOCAL_TO_NET);
        if (SPUtils.isLogined()){//登录并上传网络
            //融云登录
            ImConnect.getInstance().RongConnect(getContext());
            ll_nologin.setVisibility(View.GONE);
            ll_login.setVisibility(View.VISIBLE);
            iv_edit.setVisibility(View.VISIBLE);
            rl_msg.setVisibility(View.VISIBLE);

//            if (ltn) {
//            adapter = new MyCoverListOnNetAdapter(getContext(), new ArrayList<UserCenterData.ListBean>());
//            lv_my_playlist.setAdapter(adapter);
//            lv_my_playlist.setOnItemClickListener(new AdapterView.OnItemClickListener() {
//                @Override
//                public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
//                    String audio_num = adapter.getItem(position).getAudio_num();
//                    int num = Integer.valueOf(audio_num);
//                    if (num > 0){
//                        Intent intent = new Intent(getContext(), MyCoverDetailOnNetActivity.class);
////                    Bundle bundle = new Bundle();
////                    bundle.putSerializable(LOCAL,(DBFloatPlaylist)mPlaylist.get(position));
////                    intent.putExtras(bundle);
//                        intent.putExtra("cover_id",adapter.getItem(position).getId());
//                        //我的播单点击
////                    MobclickAgent.onEvent(getActivity().getApplicationContext(), MobClickHelper.CLOT_FEED,mPlaylist.get(position).getList_name());
////                    HashMap<String,Object> temp = new HashMap<>();
////                    temp.put("我的播单点击",mPlaylist.get(position).getList_name().toString());
////                    ZhugeSDK.getInstance().track(getActivity().getApplicationContext(),MobClickHelper.CLOT_FEED,temp);
//
//                        getContext().startActivity(intent);
//                    }
//
//                }
//            });
//            }else{
//                loadLocal();
//            }
//            iv_add_cover.setOnClickListener(new View.OnClickListener() {
//                @Override
//                public void onClick(View view) {
//                    //我的播单创建
//                    MobclickAgent.onEvent(getActivity().getApplicationContext(), MobClickHelper.CLOT_BUILD);
//                    ZhugeSDK.getInstance().track(getActivity().getApplicationContext(),MobClickHelper.CLOT_BUILD);
//
//                    getActivity().startActivity(new Intent(getActivity(), CreateNetPlaylistActivity.class));
//                }
//            });
            loadData();
        }else{
            ll_nologin.setVisibility(View.VISIBLE);
            ll_login.setVisibility(View.GONE);
            iv_edit.setVisibility(View.GONE);
            rl_msg.setVisibility(View.GONE);
            ci_header.setImageResource(R.drawable.icon_login_header);

            loadLocal();
        }

        bindJG();

    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void jpush(JPush jPush){
        bindJG();
    }

    private void bindJG(){
        String url = HttpConfig.PUSH;
        String registrationID = JPushInterface.getRegistrationID(getContext());
        if (TextUtils.isEmpty(registrationID)){
            registrationID = SPUtils.getString(SPUtils.REGISTRATION_ID);
        }
        TreeMap<String,String> treeMap = new TreeMap<>();
        treeMap.put("uid",SPUtils.getLoginUid());
        treeMap.put("deviceToken",registrationID);
        HttpClient.getInstance().postRxAndroidAES(url,treeMap)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<ResponseData>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(ResponseData responseData) {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }

    private void loadLocal(){
//        mMyPlaylistAdapter = new MyPlaylistAdapter(getActivity().getApplicationContext(),new ArrayList<DBFloatPlaylist>());
//        lv_my_playlist.setAdapter(mMyPlaylistAdapter);
//        lv_my_playlist.setOnItemClickListener(new AdapterView.OnItemClickListener() {
//            @Override
//            public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
//                Intent intent = new Intent(getContext(), PlayDetailMineActivity.class);
//                Bundle bundle = new Bundle();
//                bundle.putSerializable(LOCAL,(DBFloatPlaylist)mPlaylist.get(position));
//                intent.putExtras(bundle);
//
//                //我的播单点击
//                MobclickAgent.onEvent(getActivity().getApplicationContext(), MobClickHelper.CLOT_FEED,mPlaylist.get(position).getList_name());
//                HashMap<String,Object> temp = new HashMap<>();
//                temp.put("我的播单点击",mPlaylist.get(position).getList_name().toString());
//                ZhugeSDK.getInstance().track(getActivity().getApplicationContext(),MobClickHelper.CLOT_FEED,temp);
//
//                getContext().startActivity(intent);
//            }
//        });

//        iv_add_cover.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                //我的播单创建
//                MobclickAgent.onEvent(getActivity().getApplicationContext(), MobClickHelper.CLOT_BUILD);
//                ZhugeSDK.getInstance().track(getActivity().getApplicationContext(),MobClickHelper.CLOT_BUILD);
//
//                getActivity().startActivity(new Intent(getActivity(), CreatePlaylistActivity.class));
//            }
//        });
        queryMyList();
    }

    private void queryMyList(){
//        if(mMyPlaylistAdapter!=null){
//            mPlaylist = DBHelper.getInstance(getActivity()).queryAllList();
        mPlaylist = DBFloatPlayListDaoHelp.loadAll(getActivity());


        initTableNum(mPlaylist.size()+"","0","0");
//            mMyPlaylistAdapter.setList(mPlaylist);
//        MyCoverFragment myCoverFragment = (MyCoverFragment) userCenterViewpagerAdapter.getItem(0);
//        myCoverFragment.setData(mPlaylist);
//        }
    }

    private void initTableNum(String cover_num ,String audio_num,String post_num){
        TabLayout.Tab tab1 = tabLayout.getTabAt(0);
        tab1.setText("收藏"+cover_num);
//        tabLayout.addTab(tab1);

        TabLayout.Tab tab2 = tabLayout.getTabAt(1);
        tab2.setText("声音"+audio_num);
//        tabLayout.addTab(tab1);

        TabLayout.Tab tab3 = tabLayout.getTabAt(2);
        tab3.setText("动态"+post_num);
//        tabLayout.addTab(tab1);



    }


    private void initData(final UserCenterData userCenterData){

        UserCenterData.TabNumBean tab_num = userCenterData.getTab_num();
        String cover_num = tab_num.getCover_num();
        String audio_num = tab_num.getAudio_num();
        String post_num = tab_num.getPost_num();
        initTableNum(cover_num,audio_num,post_num);





//        boolean ltn = SPUtils.getBoolean(SPUtils.LOCAL_TO_NET);
//        if (ltn) {
//        List<UserCenterData.ListBean> list = userCenterData.getList();
//        MyCoverFragment myCoverFragment = (MyCoverFragment) userCenterViewpagerAdapter.getItem(0);
//        myCoverFragment.setData((ArrayList<UserCenterData.ListBean>) list);
//        adapter.setList(list);
//        }
        UserCenterData.AuthorBean author = userCenterData.getAuthor();
        String avator = author.getAvator();
//        String birth = author.getBirth();
//        String is_delay = author.getIs_delay();
//        String is_popup = author.getIs_popup();
        String nickname = author.getNickname();
        String sex = author.getSex();
        String sign = author.getSign();
        String uid = author.getUid();
        String new_birth = author.getNew_birth();

        String news_num = userCenterData.getNews_num();
        if (!TextUtils.isEmpty(news_num) && !TextUtils.equals("0",news_num)){
            integer_msg_num = Integer.valueOf(news_num);
            setMsgNum(chat_msg_num,integer_msg_num);
        }else{
            integer_msg_num = 0;
            setMsgNum(chat_msg_num,integer_msg_num);
        }


        tv_nickname.setText(nickname);
        if (TextUtils.isEmpty(new_birth) || TextUtils.equals("0",new_birth)){
            tv_age.setVisibility(View.VISIBLE);
            tv_age.setText("0岁");
        }else{
            tv_age.setVisibility(View.VISIBLE);
            Calendar calendar = Calendar.getInstance();
            int i1 = calendar.get(Calendar.YEAR);
            calendar.setTimeInMillis(Long.valueOf(new_birth)*1000);
            int i = calendar.get(Calendar.YEAR);
            int m = i1-i;
            tv_age.setText(m+"岁");
        }
        tv_id.setText("ID:"+uid);

        if (TextUtils.equals("1",sex)){
            tv_gander.setText("男");
            Drawable drawable = getContext().getResources().getDrawable(R.drawable.boy);
            drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
            tv_gander.setCompoundDrawables(drawable,null,null,null);
            tv_gander.setBackgroundResource(R.drawable.shape_man_bg);
            tv_age.setBackgroundResource(R.drawable.shape_man_bg);
        }else if (TextUtils.equals("2",sex)){
            tv_gander.setText("女");
            Drawable drawable = getContext().getResources().getDrawable(R.drawable.girl);
            drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
            tv_gander.setCompoundDrawables(drawable,null,null,null);
            tv_gander.setBackgroundResource(R.drawable.shape_woman_bg);
            tv_age.setBackgroundResource(R.drawable.shape_woman_bg);
        }else{
            tv_gander.setText("性别保密");
//            Drawable drawable = getContext().getResources().getDrawable(R.drawable.boy);
//            drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
            tv_gander.setCompoundDrawables(null,null,null,null);
            tv_gander.setBackgroundResource(R.drawable.shape_ufo_bg);
            tv_age.setBackgroundResource(R.drawable.shape_ufo_bg);
        }
        if (TextUtils.isEmpty(sign)){
            tv_sign.setText("这个人还没有个性签名哦");
        }else {
            tv_sign.setText(sign);
        }
        RequestOptions options = new RequestOptions();
        options.placeholder(R.drawable.icon_login_header).error(R.drawable.icon_login_header);
        Glide.with(getContext()).asBitmap().load(avator).apply(options).into(ci_header);
    }

    private void loadData(){
        String url = HttpConfig.USER_CENTER;
        TreeMap<String,String> treeMap = new TreeMap<>();
        treeMap.put("auth_key", SPUtils.getLoginAuthKey());
        HttpClient.post(url, treeMap, new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {

            }

            @Override
            public void onResponse(Call call, String response) {
//                String s = response.body().string();
                ArrayList<Map<String, String>> listMapByJson = JSONUtils.getListMapByJson(response);
                if (listMapByJson.size()>0){
                    Map<String, String> map = listMapByJson.get(0);
                    if (TextUtils.equals("200",map.get("code"))){
                        String data = map.get("data");
                        //存储用户中心数据
                        SPUtils.putString(SPUtils.USER_CENTER,data);

                        final UserCenterData userCenterData = new Gson().fromJson(data, UserCenterData.class);
                        //存储用户的个人数据
                        SPUtils.setLoginUser(userCenterData.getAuthor());
                        getActivity().runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                EventBus.getDefault().post(new LoginFloat(userCenterData));
                                initData(userCenterData);
                            }
                        });


//                        ArrayList<Map<String, String>> dataList = JSONUtils.getListMapByJson(data);
//                        Map<String, String> dataMap = dataList.get(0);
//                        String author = dataMap.get("author");
//                        String list = dataMap.get("list");
                    }else{
//                        SPUtils.clearLogin();
//                        getActivity().runOnUiThread(new Runnable() {
//                            @Override
//                            public void run() {
//                                initData();
//                            }
//                        });
                    }
                }
            }
        });
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        RongIM.getInstance().removeUnReadMessageCountChangedObserver(iUnReadMessageObserver);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.ib_setting:
                //埋点
                MobclickAgent.onEvent(getContext(), MobClickHelper.PROFILE_SETING);
//                HashMap<String, Object> temp = new HashMap<>();
//                temp.put("登录返回", "");
                ZhugeSDK.getInstance().track(getContext(), MobClickHelper.PROFILE_SETING);
                Intent intent = new Intent(getContext(), SettingActivity.class);
                startActivity(intent);
                break;
            case R.id.ll_nologin:
                //埋点
                MobclickAgent.onEvent(getContext(), MobClickHelper.PROFILE_LOGIN);
//                HashMap<String, Object> temp = new HashMap<>();
//                temp.put("登录返回", "");
                ZhugeSDK.getInstance().track(getContext(), MobClickHelper.PROFILE_LOGIN);
                Intent intent1 = new Intent(getContext(), LoginRegistActivity.class);
                startActivity(intent1);
                break;
            case R.id.ci_header:
                if (SPUtils.isLogined()){
                    //埋点
                    MobclickAgent.onEvent(getContext(), MobClickHelper.PROFILE_INFO);
//                HashMap<String, Object> temp = new HashMap<>();
//                temp.put("登录返回", "");
                    ZhugeSDK.getInstance().track(getContext(), MobClickHelper.PROFILE_INFO);
                    Intent intent2 = new Intent(getContext(), UserEditInformation.class);
                    startActivity(intent2);
                }else{
                    //埋点
                    MobclickAgent.onEvent(getContext(), MobClickHelper.PROFILE_LOGIN);
//                HashMap<String, Object> temp = new HashMap<>();
//                temp.put("登录返回", "");
                    ZhugeSDK.getInstance().track(getContext(), MobClickHelper.PROFILE_LOGIN);
                    Intent intent2 = new Intent(getContext(), LoginRegistActivity.class);
                    startActivity(intent2);
                }
                break;
            case R.id.rl_msg:
                //我的消息
                Intent intent2 = new Intent(getContext(),MyMessageActivity.class);
                startActivity(intent2);
                MobclickAgent.onEvent(getContext(),"profile_message");
                break;
            case R.id.ll_login:
//                Intent intent3 = new Intent(getContext(), UserEditInformation.class);
//                startActivity(intent3);
                break;
        }
    }
}
